package com.dmgis.hndz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.dmgis.hndz.service.JobMakeService;
import com.dmgis.hndz.mapper.JobMakeMapper;
import com.dmgis.hndz.pojo.JobMake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class JobMakeServiceImpl implements JobMakeService {
    @Autowired
    private JobMakeMapper jobMakeMapper;

    @Override
    public List<JobMake> getList() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("recentmaketime");
        return jobMakeMapper.selectList(null);
    }

    @Override
    public List<JobMake> getList1() {
        return jobMakeMapper.selectList(null);
    }

    @Override
    public Integer updateJobMake(String jobtype, Date recentmaketime) {
        JobMake jobMake = new JobMake();
        jobMake.setRecentmaketime(recentmaketime);
        LambdaUpdateWrapper<JobMake> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(JobMake::getJobtype,jobtype);
        int rows = jobMakeMapper.update(jobMake,updateWrapper);
        return rows;
    }

    @Override
    public Integer update(JobMake jobMake) {
        return jobMakeMapper.update(jobMake, Wrappers.<JobMake>lambdaUpdate()
                .eq(JobMake::getJobname,jobMake.getJobname())
                .eq(JobMake::getJobtype,jobMake.getJobtype()));
    }

    @Override
    public Integer update1(JobMake jobMake) {
        return jobMakeMapper.update(jobMake,Wrappers.<JobMake>lambdaUpdate()
                .eq(JobMake::getJobtype,jobMake.getJobtype()));
    }
}
